﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;

namespace Sims3Package.Wrapper
{
    /// <summary>
    /// Wrapper for image resource
    /// </summary>
    public class ImageResourceWrapper : Wrapper
    {
        /// <summary>
        /// Used in refection for get types
        /// </summary>
        public new static List<UInt32> ResourceTypes { get { return new List<UInt32>(mResourceTypes); } }
        private new static UInt32[] mResourceTypes = { 0x0580A2B4U, 0x0580A2B5U, 0x0580A2B6U, 0x0580A2CDU, 0x0580A2CEU,
                                                     0x0580A2CFU,0x0589DC44U, 0x0589DC45U, 0x0589DC46U, 0x0589DC47U,
                                                     0x05B17698U, 0x05B17699U, 0x05B1769AU, 0x05B1B524U, 0x05B1B525U,
                                                     0x05B1B526U, 0x0668F635U, 0x2653E3C8U, 0x2653E3C9U, 0x2653E3CAU, 
                                                     0x2D4284F0U, 0x2D4284F1U, 0x2D4284F2U, 0x2E75C764U, 0x2E75C765U,
                                                     0x2E75C766U, 0x2E75C767U, 0x5DE9DBA0U, 0x2F7D0004U, 0x5DE9DBA1U, 
                                                     0x5DE9DBA2U, 0x626F60CCU, 0x626F60CDU, 0x626F60CEU, 0x6B6D837DU, 
                                                     0x6B6D837EU, 0x6B6D837FU, 0xAD366F95U, 0xAD366F96U, 0xD84E7FC5U,
                                                     0xD84E7FC6U, 0xD84E7FC7U, 0xFCEAB65B};
        /// <summary>
        /// Image value
        /// </summary>
        public Image ImageValue { get; set; }
        /// <summary>
        /// Standard constructor
        /// </summary>
        /// <param name="s">Stream that contained in entry, null to represent new resource</param>
        public ImageResourceWrapper(Stream s) : base(s) { stream = s; stream.Position = 0; ImageValue = Image.FromStream(stream); }
        /// <summary>
        /// Returns the stream written into entry
        /// </summary>
        /// <returns>Stream.IO.Stream</returns>
        public override Stream UnParse()
        {
            if (ImageValue != null) { MemoryStream s = new MemoryStream(); ImageValue.Save(s, System.Drawing.Imaging.ImageFormat.Png); }
            return null;
        }
        /// <summary>
        /// Used in text preview
        /// </summary>
        public override string Value { get { return string.Empty; } }
    }
}
